//
//  File.swift
//  StudentPerformance
//
//  Created by ap0stader on 2023/11/21.
//

import UIKit

class DetailController : UIViewController {
    
    @IBOutlet var name: UITextField!
    
    @IBOutlet var id: UITextField!
    
    @IBOutlet var score: UITextField!
    
    var theStudent: Student! {
        didSet {
            navigationItem.title = theStudent.name
        }
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        name.text = theStudent.name
        id.text = theStudent.id
        score.text = "\(theStudent.score)"
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        theStudent.name = name.text!
        theStudent.id = id.text!
        theStudent.score = Int16(score.text!)!
    }
    
    @IBAction func dismisskeyboard(_ sender: Any) {
        name.resignFirstResponder()
        id.resignFirstResponder()
        score.resignFirstResponder()
    }
    
}
